import { EggAppConfig, PowerPartial } from 'egg';

export default () => {
  const config: PowerPartial<EggAppConfig> = {};

  // mysql 数据库配置
  config.sequelize = {
    datasources: [
      {
        delegate: 'model',
        baseDir: 'model',
        dialect: 'mysql',
        host: process.env.APP_MYSQL_HOST || '127.0.0.1',
        port: Number(process.env.APP_MYSQL_PORT) || 3306,
        username: process.env.APP_MYSQL_USERNAME || 'root',
        password: process.env.APP_MYSQL_PASSWORD || 'root',
        database: process.env.APP_MYSQL_DATABASE || 'foo',
        define: {
          // 取消复数
          freezeTableName: true,
          // 字符集
          charset: 'utf8mb4',
          collate: 'utf8mb4_general_ci',
          // 时间戳
          timestamps: false,
        },
        pool: {
          min: 0,
          max: 200,
        }
      }
    ]
  };

  // redis配置
  config.redis = {
    client: {
      port: Number(process.env.APP_REDIS_PORT) || 6379,
      host: process.env.APP_REDIS_HOST || '127.0.0.1',
      ...(process.env.APP_REDIS_PASSWORD ? { password: process.env.APP_REDIS_PASSWORD } : {}),
      ...(process.env.APP_REDIS_DB ? { db: Number(process.env.APP_REDIS_DB) } : {}),
    }
  };

  // // wps配置
  // config.wps = {
  //   online_editing: {
  //     domain: process.env.APP_WPS_DOMAIN || 'https://wwo.wps.cn',
  //     appId: process.env.APP_WPS_APPID || '22585c948e4f46439901e3fb8f334566',
  //     appKey: process.env.APP_WPS_APPKEY || '7fa941eff128413f8d8a49586683e273',
  //     expireIn: 600
  //   }
  // };
  //
  // // 微信配置
  // config.wechat = {
  //   oa: {
  //     appid: process.env.APP_WECHAT_OA_APPID || 'wxcef2cf418c141e7f',
  //     secret: process.env.APP_WECHAT_OA_SECRET || '03487c89051bbbba72beb0abbb622772',
  //     token: process.env.APP_WECHAT_OA_TOKEN || 'rdd',
  //     key: process.env.APP_WECHAT_OA_KEY || 'Ff8yqH9c9qL6fnBmp4F6WwqiNPNNL90TKvYwhMAob9o'
  //   },
  //   pmp: {
  //     appid: '',
  //     secret: ''
  //   }
  // };
  //
  // // 报修配置
  // config.repair = {
  //   special_user_ids: []
  // };
  //
  // // oss
  // config.oss = {
  //   client: {
  //       accessKeyId: process.env.APP_ALI_OSS_KEY || 'LTAI5t5ztVrxnpicsez1heqV',
  //       accessKeySecret: process.env.APP_ALI_OSS_SECRET || 'ssWQnhusoqAIrMivLSvVZqQFjLi9Eo',
  //       bucket: process.env.APP_ALI_OSS_BUCKET || 'wmy-saas',
  //       cname: true,
  //       endpoint: process.env.APP_ALI_OSS_ENDPOINT || 'https://wmy-saas.oss-cn-shanghai.aliyuncs.com',
  //       timeout: '60s',
  //   },
  // };
  //
  // // 腾讯
  // config.tencent = {
  //   secretId: process.env.APP_TENCENT_SECRET_ID || 'AKIDiDScYM48gyzjGXcLzmJbcLHxLSJxvhp9',
  //   secretKey: process.env.APP_TENCENT_SECRET_KEY || 'KQHG1ZrvkJceXGVqIXYM0PksvkkU4OaZ',
  //   sms: {
  //     sdkAppId: '1400390364',
  //     signName: '万名',
  //   }
  // };

  return config;
};
